<template><div><h2 id="错误处理" tabindex="-1"><a class="header-anchor" href="#错误处理"><span>错误处理</span></a></h2>
<p>Yii 内置了一个 <code v-pre>yii\web\ErrorHandler</code> 错误处理器，它使错误处理更方便，Yii 错误处理器做以下工作来提升错误处理效果：</p>
<ul>
<li>所有非致命PHP错误（如，警告，提示）会转换成可获取异常；</li>
<li>异常和致命的PHP错误会被显示， 在调试模式会显示详细的函数调用栈和源代码行数。</li>
<li>支持使用专用的 <a href="https://github.com/yiisoft/yii2/blob/master/docs/guide-zh-CN/structure-controllers.md#actions" target="_blank" rel="noopener noreferrer">控制器动作</a> 来显示错误；</li>
<li>支持不同的错误响应格式。</li>
</ul>
<p><code v-pre>yii\web\ErrorHandler</code> 错误处理器默认启用，可通过在应用的 <a href="https://github.com/yiisoft/yii2/blob/master/docs/guide-zh-CN/structure-entry-scripts.md" target="_blank" rel="noopener noreferrer">入口脚本</a> 中定义常量 <code v-pre>YII_ENABLE_ERROR_HANDLER</code> 来禁用。</p>
<h2 id="使用错误处理器" tabindex="-1"><a class="header-anchor" href="#使用错误处理器"><span>使用错误处理器</span></a></h2>
<p><code v-pre>yii\web\ErrorHandler</code> 注册成一个名称为 <code v-pre>errorHandler</code> <a href="https://github.com/yiisoft/yii2/blob/master/docs/guide-zh-CN/structure-application-components.md" target="_blank" rel="noopener noreferrer">应用组件</a>，可以在应用配置中配置它类似如下：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">return</span> <span class="token punctuation">[</span></span>
<span class="line">    <span class="token string single-quoted-string">'components'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">        <span class="token string single-quoted-string">'errorHandler'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">            <span class="token string single-quoted-string">'maxSourceLines'</span> <span class="token operator">=></span> <span class="token number">20</span><span class="token punctuation">,</span></span>
<span class="line">        <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line"><span class="token punctuation">]</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>使用如上代码，异常页面最多显示20条源代码。</p>
<p>如前所述，错误处理器将所有非致命 PHP 错误转换成可获取异常，也就是说可以使用如下代码处理 PHP 错误：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">use</span> <span class="token package">Yii</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token keyword">use</span> <span class="token package">yii<span class="token punctuation">\</span>base<span class="token punctuation">\</span>ErrorException</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">try</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token number">10</span><span class="token operator">/</span><span class="token number">0</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span> <span class="token keyword">catch</span> <span class="token punctuation">(</span><span class="token class-name">ErrorException</span> <span class="token variable">$e</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">    <span class="token class-name static-context">Yii</span><span class="token operator">::</span><span class="token function">warning</span><span class="token punctuation">(</span><span class="token string double-quoted-string">"Division by zero."</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span>
<span class="line"><span class="token comment">// execution continues...</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>如果你想显示一个错误页面告诉用户请求是无效的或无法处理的，可简单地抛出一个 <code v-pre>yii\web\HttpException</code> HTTP 异常，如 <code v-pre>yii\web\NotFoundHttpException</code>。错误处理器会正确地设置响应的 HTTP 状态码并使用合适的错误视图页面来显示错误信息。</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">use</span> <span class="token package">yii<span class="token punctuation">\</span>web<span class="token punctuation">\</span>NotFoundHttpException</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">throw</span> <span class="token keyword">new</span> <span class="token class-name">NotFoundHttpException</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="自定义错误显示" tabindex="-1"><a class="header-anchor" href="#自定义错误显示"><span>自定义错误显示</span></a></h2>
<p><code v-pre>yii\web\ErrorHandler</code> 错误处理器，根据常量 <code v-pre>YII_DEBUG</code> 的值来调整错误显示，当<code v-pre>YII_DEBUG</code> 为 true (表示在调试模式)，错误处理器会显示异常以及详细的函数调用栈和源代码行数来帮助调试，当 <code v-pre>YII_DEBUG</code> 为 false，只有错误信息会被显示以防止应用的敏感信息泄漏。</p>
<blockquote>
<p>Info: 如果异常是继承 <code v-pre>yii\base\UserException</code>，不管 <code v-pre>YII_DEBUG</code> 为何值，函数调用栈信息都不会显示，这是因为这种错误会被认为是用户产生的错误，开发人员不需要去修正。</p>
</blockquote>
<p><code v-pre>yii\web\ErrorHandler</code> 错误处理器，默认使用两个 <a href="https://github.com/yiisoft/yii2/blob/master/docs/guide-zh-CN/structure-views.md" target="_blank" rel="noopener noreferrer">视图</a> 显示错误:</p>
<ul>
<li><code v-pre>@yii/views/errorHandler/error.php</code>: 显示不包含函数调用栈信息的错误信息是使用，当 <code v-pre>YII_DEBUG</code> 为 false 时，所有错误都使用该视图。</li>
<li><code v-pre>@yii/views/errorHandler/exception.php</code>: 显示包含函数调用栈信息的错误信息时使用。</li>
</ul>
<p>可以配置错误处理器的 <code v-pre>yii\web\ErrorHandler::errorView</code> 和 <code v-pre>yii\web\ErrorHandler::exceptionView</code> 属性，使用自定义的错误显示视图。</p>
<h3 id="使用错误动作" tabindex="-1"><a class="header-anchor" href="#使用错误动作"><span>使用错误动作</span></a></h3>
<p>使用指定的错误 <a href="https://github.com/yiisoft/yii2/blob/master/docs/guide-zh-CN/structure-controllers.md" target="_blank" rel="noopener noreferrer">动作</a> 来自定义错误显示更方便，为此，首先配置 <code v-pre>errorHandler</code> 组件的 <code v-pre>yii\web\ErrorHandler::errorAction</code> 属性，类似如下：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">return</span> <span class="token punctuation">[</span></span>
<span class="line">    <span class="token string single-quoted-string">'components'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">        <span class="token string single-quoted-string">'errorHandler'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">            <span class="token string single-quoted-string">'errorAction'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'site/error'</span><span class="token punctuation">,</span></span>
<span class="line">        <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token punctuation">]</span></span>
<span class="line"><span class="token punctuation">]</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><code v-pre>yii\web\ErrorHandler::errorAction</code> 属性使用 <a href="https://github.com/yiisoft/yii2/blob/master/docs/guide-zh-CN/structure-controllers.md#routes" target="_blank" rel="noopener noreferrer">路由</a> 到一个动作，上述配置表示，不用显示函数调用栈信息的错误，会通过执行 <code v-pre>site/error</code> 操作来显示，可以创建 <code v-pre>site/error</code> 动作，如下所示：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">namespace</span> <span class="token package">app<span class="token punctuation">\</span>controllers</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">use</span> <span class="token package">Yii</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token keyword">use</span> <span class="token package">yii<span class="token punctuation">\</span>web<span class="token punctuation">\</span>Controller</span><span class="token punctuation">;</span></span>
<span class="line"></span>
<span class="line"><span class="token keyword">class</span> <span class="token class-name-definition class-name">SiteController</span> <span class="token keyword">extends</span> <span class="token class-name">Controller</span></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">actions</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line">    <span class="token punctuation">{</span></span>
<span class="line">        <span class="token keyword">return</span> <span class="token punctuation">[</span></span>
<span class="line">            <span class="token string single-quoted-string">'error'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">                <span class="token string single-quoted-string">'class'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'yii\web\ErrorAction'</span><span class="token punctuation">,</span></span>
<span class="line">            <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line">        <span class="token punctuation">]</span><span class="token punctuation">;</span></span>
<span class="line">    <span class="token punctuation">}</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>上述代码定义 <code v-pre>error</code> 操作使用 <code v-pre>yii\web\ErrorAction</code> 类，该类渲染名为 <code v-pre>error</code> 视图来显示错误。</p>
<p>除了使用 <code v-pre>yii\web\ErrorAction</code>，可定义 <code v-pre>error</code> 动作使用类似如下的动作方法：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">public</span> <span class="token keyword">function</span> <span class="token function-definition function">actionError</span><span class="token punctuation">(</span><span class="token punctuation">)</span></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token variable">$exception</span> <span class="token operator">=</span> <span class="token class-name static-context">Yii</span><span class="token operator">::</span><span class="token variable">$app</span><span class="token operator">-></span><span class="token property">errorHandler</span><span class="token operator">-></span><span class="token property">exception</span><span class="token punctuation">;</span></span>
<span class="line">    <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token variable">$exception</span> <span class="token operator">!==</span> <span class="token constant">null</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">        <span class="token keyword">return</span> <span class="token variable">$this</span><span class="token operator">-></span><span class="token function">render</span><span class="token punctuation">(</span><span class="token string single-quoted-string">'error'</span><span class="token punctuation">,</span> <span class="token punctuation">[</span><span class="token string single-quoted-string">'exception'</span> <span class="token operator">=></span> <span class="token variable">$exception</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line">    <span class="token punctuation">}</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>现在应创建一个视图文件为 <code v-pre>views/site/error.php</code>，在该视图文件中，如果错误动作定义为 <code v-pre>yii\web\ErrorAction</code>，可以访问该动作中定义的如下变量：</p>
<ul>
<li><code v-pre>name</code>: 错误名称</li>
<li><code v-pre>message</code>: 错误信息</li>
<li><code v-pre>exception</code>: 更多详细信息的异常对象，如 HTTP 状态码，错误码，错误调用栈等。</li>
</ul>
<blockquote>
<p>Note: 如果你使用 <a href="https://github.com/yiisoft/yii2/blob/master/docs/guide-zh-CN/start-installation.md" target="_blank" rel="noopener noreferrer">基础应用模板</a> 或 <a href="https://github.com/yiisoft/yii2/blob/master/docs/guide-zh-CN/tutorial-advanced-app.md" target="_blank" rel="noopener noreferrer">高级应用模板</a>，错误动作和错误视图已经定义好了。</p>
</blockquote>
<blockquote>
<p>Note: 如果您需要在错误处理程序中重定向，请执行以下操作：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token class-name static-context">Yii</span><span class="token operator">::</span><span class="token variable">$app</span><span class="token operator">-></span><span class="token function">getResponse</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">redirect</span><span class="token punctuation">(</span><span class="token variable">$url</span><span class="token punctuation">)</span><span class="token operator">-></span><span class="token function">send</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></span>
<span class="line"><span class="token keyword">return</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div></div></div></blockquote>
<h3 id="自定义错误格式" tabindex="-1"><a class="header-anchor" href="#自定义错误格式"><span>自定义错误格式</span></a></h3>
<p>错误处理器根据 <a href="https://github.com/yiisoft/yii2/blob/master/docs/guide-zh-CN/runtime-responses.md" target="_blank" rel="noopener noreferrer">响应</a> 设置的格式来显示错误，如果 <code v-pre>yii\web\Response::format</code> 响应格式为 <code v-pre>html</code>，会使用错误或异常视图来显示错误信息，如上一小节所述。对于其他的响应格式，错误处理器会错误信息作为数组赋值给 [[yii\web\Response::data]] 属性，然后转换到对应的格式，例如，如果响应格式为 <code v-pre>json</code>，可以看到如下响应信息：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token constant">HTTP</span><span class="token operator">/</span><span class="token number">1.1</span> <span class="token number">404</span> Not Found</span>
<span class="line">Date<span class="token punctuation">:</span> Sun<span class="token punctuation">,</span> <span class="token number">02</span> Mar <span class="token number">2014</span> <span class="token number">05</span><span class="token punctuation">:</span><span class="token number">31</span><span class="token punctuation">:</span><span class="token number">43</span> <span class="token constant">GMT</span></span>
<span class="line">Server<span class="token punctuation">:</span> Apache<span class="token operator">/</span><span class="token number">2.2</span><span class="token number">.26</span> <span class="token punctuation">(</span>Unix<span class="token punctuation">)</span> <span class="token constant">DAV</span><span class="token operator">/</span><span class="token number">2</span> <span class="token constant">PHP</span><span class="token operator">/</span><span class="token number">5.4</span><span class="token number">.20</span> mod_ssl<span class="token operator">/</span><span class="token number">2.2</span><span class="token number">.26</span> OpenSSL<span class="token operator">/</span><span class="token number">0.9</span><span class="token number">.8</span>y</span>
<span class="line">Transfer<span class="token operator">-</span>Encoding<span class="token punctuation">:</span> chunked</span>
<span class="line">Content<span class="token operator">-</span>Type<span class="token punctuation">:</span> application<span class="token operator">/</span>json<span class="token punctuation">;</span> charset<span class="token operator">=</span><span class="token constant">UTF</span><span class="token operator">-</span><span class="token number">8</span></span>
<span class="line"></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token string double-quoted-string">"name"</span><span class="token punctuation">:</span> <span class="token string double-quoted-string">"Not Found Exception"</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token string double-quoted-string">"message"</span><span class="token punctuation">:</span> <span class="token string double-quoted-string">"The requested resource was not found."</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token string double-quoted-string">"code"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token string double-quoted-string">"status"</span><span class="token punctuation">:</span> <span class="token number">404</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>可在应用配置中响应 <code v-pre>response</code> 组件的 <code v-pre>beforeSend</code> 事件来自定义错误响应格式。</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token keyword">return</span> <span class="token punctuation">[</span></span>
<span class="line">    <span class="token comment">// ...</span></span>
<span class="line">    <span class="token string single-quoted-string">'components'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">        <span class="token string single-quoted-string">'response'</span> <span class="token operator">=></span> <span class="token punctuation">[</span></span>
<span class="line">            <span class="token string single-quoted-string">'class'</span> <span class="token operator">=></span> <span class="token string single-quoted-string">'yii\web\Response'</span><span class="token punctuation">,</span></span>
<span class="line">            <span class="token string single-quoted-string">'on beforeSend'</span> <span class="token operator">=></span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token variable">$event</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">                <span class="token variable">$response</span> <span class="token operator">=</span> <span class="token variable">$event</span><span class="token operator">-></span><span class="token property">sender</span><span class="token punctuation">;</span></span>
<span class="line">                <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token variable">$response</span><span class="token operator">-></span><span class="token property">data</span> <span class="token operator">!==</span> <span class="token constant">null</span><span class="token punctuation">)</span> <span class="token punctuation">{</span></span>
<span class="line">                    <span class="token variable">$response</span><span class="token operator">-></span><span class="token property">data</span> <span class="token operator">=</span> <span class="token punctuation">[</span></span>
<span class="line">                        <span class="token string single-quoted-string">'success'</span> <span class="token operator">=></span> <span class="token variable">$response</span><span class="token operator">-></span><span class="token property">isSuccessful</span><span class="token punctuation">,</span></span>
<span class="line">                        <span class="token string single-quoted-string">'data'</span> <span class="token operator">=></span> <span class="token variable">$response</span><span class="token operator">-></span><span class="token property">data</span><span class="token punctuation">,</span></span>
<span class="line">                    <span class="token punctuation">]</span><span class="token punctuation">;</span></span>
<span class="line">                    <span class="token variable">$response</span><span class="token operator">-></span><span class="token property">statusCode</span> <span class="token operator">=</span> <span class="token number">200</span><span class="token punctuation">;</span></span>
<span class="line">                <span class="token punctuation">}</span></span>
<span class="line">            <span class="token punctuation">}</span><span class="token punctuation">,</span></span>
<span class="line">        <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token punctuation">]</span><span class="token punctuation">,</span></span>
<span class="line"><span class="token punctuation">]</span><span class="token punctuation">;</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>上述代码会重新格式化错误响应，类似如下：</p>
<div class="language-php line-numbers-mode" data-highlighter="prismjs" data-ext="php" data-title="php"><pre v-pre class="language-php"><code><span class="line"><span class="token constant">HTTP</span><span class="token operator">/</span><span class="token number">1.1</span> <span class="token number">200</span> <span class="token constant">OK</span></span>
<span class="line">Date<span class="token punctuation">:</span> Sun<span class="token punctuation">,</span> <span class="token number">02</span> Mar <span class="token number">2014</span> <span class="token number">05</span><span class="token punctuation">:</span><span class="token number">31</span><span class="token punctuation">:</span><span class="token number">43</span> <span class="token constant">GMT</span></span>
<span class="line">Server<span class="token punctuation">:</span> Apache<span class="token operator">/</span><span class="token number">2.2</span><span class="token number">.26</span> <span class="token punctuation">(</span>Unix<span class="token punctuation">)</span> <span class="token constant">DAV</span><span class="token operator">/</span><span class="token number">2</span> <span class="token constant">PHP</span><span class="token operator">/</span><span class="token number">5.4</span><span class="token number">.20</span> mod_ssl<span class="token operator">/</span><span class="token number">2.2</span><span class="token number">.26</span> OpenSSL<span class="token operator">/</span><span class="token number">0.9</span><span class="token number">.8</span>y</span>
<span class="line">Transfer<span class="token operator">-</span>Encoding<span class="token punctuation">:</span> chunked</span>
<span class="line">Content<span class="token operator">-</span>Type<span class="token punctuation">:</span> application<span class="token operator">/</span>json<span class="token punctuation">;</span> charset<span class="token operator">=</span><span class="token constant">UTF</span><span class="token operator">-</span><span class="token number">8</span></span>
<span class="line"></span>
<span class="line"><span class="token punctuation">{</span></span>
<span class="line">    <span class="token string double-quoted-string">"success"</span><span class="token punctuation">:</span> <span class="token constant boolean">false</span><span class="token punctuation">,</span></span>
<span class="line">    <span class="token string double-quoted-string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span></span>
<span class="line">        <span class="token string double-quoted-string">"name"</span><span class="token punctuation">:</span> <span class="token string double-quoted-string">"Not Found Exception"</span><span class="token punctuation">,</span></span>
<span class="line">        <span class="token string double-quoted-string">"message"</span><span class="token punctuation">:</span> <span class="token string double-quoted-string">"The requested resource was not found."</span><span class="token punctuation">,</span></span>
<span class="line">        <span class="token string double-quoted-string">"code"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span></span>
<span class="line">        <span class="token string double-quoted-string">"status"</span><span class="token punctuation">:</span> <span class="token number">404</span></span>
<span class="line">    <span class="token punctuation">}</span></span>
<span class="line"><span class="token punctuation">}</span></span>
<span class="line"></span></code></pre>
<div class="line-numbers" aria-hidden="true" style="counter-reset:line-number 0"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote>
<p>💖喜欢本文档的，欢迎点赞、收藏、留言或转发，谢谢支持！<br>
作者邮箱：zhuzixian520@126.com，github地址：<a href="https://github.com/zhuzixian520" target="_blank" rel="noopener noreferrer">github.com/zhuzixian520</a></p>
</blockquote>
</div></template>


